/**
 *  fileName:2908. 元素和最小的山形三元组 I
 *  time:2024/3/29
 *  todo:$END$
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var minimumSum = function(nums) {
  let sum = Infinity;
  let len = nums.length;
  for (let i = 0; i < len - 2; i++) {
    for (let j = i+1; j < len - 1; j++) {
      for (let k = j+1; k < len; k++) {
        if (nums[j] > nums[i] && nums[j] > nums[k]) {
          sum = Math.min(sum, nums[i] + nums[j] + nums[k])
        }
      }
    }
  }
  return sum === Infinity ? -1 : sum;
};
